package com.baidu.util;

import com.baidu.config.MainConfig;
import com.baidu.config.QuartzManager;
import com.baidu.model.BDUser;
import com.baidu.model.CloudCount;
import com.baidu.model.Cron;
import com.baidu.model.Dept;
import com.baidu.model.DictContent;
import com.baidu.model.Invite;
import com.baidu.model.MyTB;
import com.baidu.model.Reply;
import com.baidu.model.ReplyContent;
import com.baidu.model.ReplyRec;
import com.baidu.model.SysUser;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;


/**
 * 数据源、table设置
 * @author iicm
 * 2016-1-26 11:01
 */
public class PluginSet {
	
	/**
     * 数据源、table设置并启动
     * @param len int
     * @return String
     */
    public static void dataSourceSet(){
		MainConfig.druidPlugin = new DruidPlugin(MainConfig.jdbc_prop.get("jdbcUrl"), MainConfig.jdbc_prop.get("username"), MainConfig.jdbc_prop.get("password"));
		MainConfig.druidPlugin.start();
		MainConfig.arp = new ActiveRecordPlugin(MainConfig.druidPlugin);
		MainConfig.arp.setDevMode(MainConfig.DEBUG);
		if(MainConfig.DEBUG == true){
			MainConfig.arp.setShowSql(true);
		}
		MainConfig.arp.addMapping("bd_user", "guid" , BDUser.class);
		MainConfig.arp.addMapping("cloud_count", "guid" , CloudCount.class);
		MainConfig.arp.addMapping("cron", "id", Cron.class);
		MainConfig.arp.addMapping("dept", "id", Dept.class);
		MainConfig.arp.addMapping("sys_invite", "guid", Invite.class);
		MainConfig.arp.addMapping("my_tb", "guid", MyTB.class);
		MainConfig.arp.addMapping("reply", "guid", Reply.class);
		MainConfig.arp.addMapping("reply_content", "id", ReplyContent.class);
		MainConfig.arp.addMapping("reply_rec", "guid", ReplyRec.class);
		MainConfig.arp.addMapping("sys_user", "guid", SysUser.class);
		MainConfig.arp.addMapping("dict_content", "id", DictContent.class);
		MainConfig.arp.start();
    }
    
    /**
     * 数据源、table设置
     * @param len int
     * @return String
     */
    public static void quartzSet(){
    	//启动定时任务
		MainConfig.jobManager = new QuartzManager();
		MainConfig.jobManager.start();
    }
    
}
